from typing import Dict, Any, Type
from .base_sender import BaseReportSender
from .email_sender import EmailSender
from .dingtalk_sender import DingTalkSender
from .wecom_sender import WeComSender

class ReportSenderFactory:
    """报告发送器工厂"""
    
    _senders: Dict[str, Type[BaseReportSender]] = {
        'email': EmailSender,
        'dingtalk': DingTalkSender,
        'wecom': WeComSender
    }
    
    @classmethod
    def get_sender(cls, sender_type: str, config: Dict[str, Any]) -> BaseReportSender:
        """获取报告发送器实例
        
        Args:
            sender_type: 发送器类型（email/dingtalk/wecom）
            config: 发送器配置信息
            
        Returns:
            报告发送器实例
            
        Raises:
            ValueError: 不支持的发送器类型
        """
        sender_class = cls._senders.get(sender_type.lower())
        if not sender_class:
            raise ValueError(f"Unsupported sender type: {sender_type}")
            
        return sender_class(config)
        
    @classmethod
    def register_sender(cls, sender_type: str, sender_class: Type[BaseReportSender]):
        """注册新的发送器类型
        
        Args:
            sender_type: 发送器类型
            sender_class: 发送器类
        """
        cls._senders[sender_type.lower()] = sender_class 